let fs = require('fs')
console.log('执行了')
let border = document.getElementById('border')
let fileBorder =document.getElementById(('files-border'))
border.addEventListener('drop',(e)=>{
    e.preventDefault()
    e.stopPropagation()
    for (const file of e.dataTransfer.files) {
        console.log(file.name)
        console.log(file.path)
        fs.readFile(file.path,(err,data)=>{
            if (err) console.error(err,'err')
            else{
                let newDiv = document.createElement('div')
                newDiv.innerHTML = `
                    <h1>${file.name}</h1>
                    <pre>${data}</pre>
                `
                fileBorder.appendChild(newDiv)
            }
        })
    }
})

border.addEventListener('dragover',(e)=>{
    e.preventDefault()
    e.stopPropagation()
    console.log('拖放结束')
})